package test;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import java.io.*;
import java.util.HashMap;
import java.util.List;

/**
 * @Description:
 * @Author: MenChao
 * @Date: 2018/12/6 14:07
 */
@WebServlet(name = "testdata")
public class testdata extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //JSONArray jsonArray =  new JSONArray();

        String savePath = this.getServletContext().getRealPath("/WEB-INF/upload");
        System.out.println( "savePath: " + savePath);



       // this.uploadFile(request,response);

    }




    private void praseJson(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{

        response.setContentType("application/json;charset=utf-8");//指定返回的格式为JSON格式
        response.setCharacterEncoding("UTF-8");//setContentType与setCharacterEncoding的顺序不能调换，否则还是无法解决中文乱码的问题


        String appName = "松果财富";
        String version = "1.8.0";
        String jsonStr = "{\"appName\":\"" + appName + "\",\"version\":" + version + "}";
        PrintWriter out = response.getWriter();
        out.write(jsonStr);
        out.close();
    }


}
